<script type="text/javascript">

    function change(){
        var csubjecttype = $('#c-csubjecttype option:selected').val();
        // 类型:1=判断题,2=单项选择题,3=多选题

        if(csubjecttype==1){
            $('#true_false').css('display','block');
            $('#mult').css('display','none');
            $('#chose').css('display','none');
            $('#option').css('display','none');
        }
        if(csubjecttype==2){
            $('#true_false').css('display','none');
            $('#mult').css('display','none');
            $('#chose').css('display','block');
            $('#option').css('display','block');
        }
        if(csubjecttype==3){
            $('#true_false').css('display','none');
            $('#mult').css('display','block');
            $('#chose').css('display','none');
            $('#option').css('display','block');
        }
    }
</script>
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Ctitle')}:</label>
        <div class="col-xs-12 col-sm-4">
            <textarea id="c-ctitle" data-rule="required" class="form-control" rows="4" name="row[ctitle]" cols="50"></textarea>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Csubjecttype')}:</label>
        <div class="col-xs-12 col-sm-8">
                        
            <select  id="c-csubjecttype" data-rule="required" onchange="change()" class="form-control selectpicker" name="row[csubjecttype]">
                {foreach name="csubjecttypeList" item="vo"}
                    <option value="{$key}" {in name="key" value=""}selected{/in}>{$vo}</option>
                {/foreach}
            </select>

        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">章节名称:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-ichapterid" data-rule="required" data-field="cchaptername" data-source="chapter/index" class="form-control selectpage" name="row[ichapterid]" type="text" value="" data-primary-key='ichapterid'>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Iscore')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-iscore" data-rule="required" class="form-control" step="0.01" name="row[iscore]" type="number">
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Cdescription')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-cdescription" class="form-control" rows="5" name="row[cdescription]" cols="50"></textarea>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">试卷来源时间:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-dchangedate" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[dchangedate]" type="text" value="{:date('Y-m-d H:i:s')}">
        </div>
    </div>

    <div id="true_false">
        <div class="form-group">
            <label class="control-label col-xs-12 col-sm-2">正确答案:</label>
            <div class="col-xs-12 col-sm-8">
                <!-- 0是错，1是对 -->
                {:build_radios('row[trueorfalse]', [1=>__('True'), 0=>__('False')])}
            </div>
        </div>
    </div>

    <div style="display: none;" id="option">
        <div class="form-group">
            <label class="control-label col-xs-12 col-sm-2">选项A:</label>
            <div class="col-xs-12 col-sm-8">
                <input id="c-A" class="form-control" name="row[A]" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-xs-12 col-sm-2">选项B:</label>
            <div class="col-xs-12 col-sm-8">
                <input id="c-B" class="form-control" name="row[B]" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-xs-12 col-sm-2">选项C:</label>
            <div class="col-xs-12 col-sm-8">
                <input id="c-C" class="form-control" name="row[C]" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-xs-12 col-sm-2">选项D:</label>
            <div class="col-xs-12 col-sm-8">
                <input id="c-D" class="form-control" name="row[D]" type="text">
            </div>
        </div>

        <div id="chose">
            <div class="form-group">
                <label class="control-label col-xs-12 col-sm-2">正确答案:</label>
                <div class="col-xs-12 col-sm-8">
                     {:build_radios('row[chose_canswer]', ['A'=>'A', 'B'=>'B', 'C'=>'C', 'D'=>'D'], '', ['data-rule'=>'required'])}
                </div>
            </div>
        </div>
        <div id="mult">

            <div class="form-group">
                <label class="control-label col-xs-12 col-sm-2">选项E:</label>
                <div class="col-xs-12 col-sm-8">
                    <input id="c-E" class="form-control" name="row[E]" type="text">
                </div>
            </div>

            <div class="form-group">
                <label class="control-label col-xs-12 col-sm-2">正确答案:</label>
                <div class="col-xs-12 col-sm-8">
                     {:Form::checkboxs('row[canswer]', ['A'=>'A', 'B'=>'B', 'C'=>'C', 'D'=>'D', 'E'=>'E'], '', ['data-rule'=>'required'])}
                </div>
            </div>
        </div>
    </div>

    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>
